#region Using Statements
using System;
using System.Collections.Generic;
using Graphics;
using System.Drawing;
using ImagesMath;
using ImagesMath.Transformations;
using Graphics.Geometries;
using Graphics.Films;
using System.Windows.Forms;
#endregion

namespace RayGraphics
{

    public class SceneController
    {
        private Studio studio;
        private Film film;
        private Camera camera;
        private int dimension;
        private bool reflection;
        private bool transmission;
        private RayTracer ray;


        public SceneController(int dimension, bool reflection, bool transmission)
        {
            this.reflection = reflection;
            this.transmission = transmission;
            this.dimension = dimension;
            studio = new Studio();
            ray = new RayTracer();



        }

        public bool Reflection
        {
            get { return this.reflection; }
            set { this.reflection = value; }
        }

        public bool Transmission
        {
            get { return this.transmission; }
            set { this.transmission = value; }
        }

        public void SetLight(Light light)
        {
            studio.Lights.Clear();
            studio.Lights.Add(light);
        }
        public void SetFilm(Film film)
        {
            this.film = film;
        }

        public void SetCamera(Camera camera)
        {
            studio.SetMaxDepth(4);
            //this.film = new FilmColorAna(Film.TYPE.T24x36, this.dimension, this.dimension);
            this.camera = camera;
            this.camera.SetFilm(this.film);
            ray.SetCamera(camera);
            ray.SetFilm(film);
            this.camera.UpdateCameraTransform(camera.Position, camera.LookAt, camera.Up);
            
        }

        public Bitmap GetRenderImage()
        {
            return (film as FilmColorAna).GetImage();
        }

        public void Render()
        {
            ray.Shoot(studio, 1, reflection, transmission);
        }

        public void Render(ref ProgressBar bar)
        {
            ray.Shoot(studio, 1, reflection, transmission, ref bar);
        }

        public List<Graphics.Object3D> Objects
        {
            get { return this.studio.Objects; }
            set { this.studio.Objects = value; }
        }

        public List<Graphics.Light> Lights
        {
            get { return this.studio.Lights; }
            set { this.studio.Lights = value; }
        }

    }
}


